x86/hvm: Correct the emulated interaction of invlpg with segments
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 22 Apr 2016 08:44:53 +0000 (09:44 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 10 May 2016 17:08:55 +0000 (18:08 +0100)
commita373db28eaa1e9011db00cc6359b8ee1112c80e0
tree66f592100e47ee30f3e05069ae495d2a45c46735
parenta94b35ddedf5c7327c6b2d9205d0a2aef2e4cfed
x86/hvm: Correct the emulated interaction of invlpg with segments

The `invlpg` instruction is documented to take a memory address, and is not
documented to suffer faults from segmentation violations.  It is also
explicitly documented to be a NOP when issued on a non-canonical address.

Experimentally, and subsequently confirmed by both Intel and AMD, the
instruction does take into account segment bases, but will happily invalidate
a TLB entry for a mapping beyond the segment limit.

The emulation logic will currently raise #GP/#SS faults for segment limit
violations, or non-canonical addresses, which doesn't match hardware's
behaviour.  Instead, squash exceptions generated by
hvmemul_virtual_to_linear() and proceed with invalidation.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
xen/arch/x86/hvm/emulate.c